import { type  Router } from 'vue-router'
import { busy, idle } from '@/common/infrastructure/nprogress'

/**
 * 路由守卫生成器
 * @param router - 路由
 * */
export default function(router:Router) {
    /**
     * 路油导航前
     */
    router.beforeEach((to, from, next) => {

        // TODO 权限拦截
        try {
            busy()
            next()
        }
        finally {
            idle()
        }
    })

    /**
     * 路由导航后
     * */
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    router.afterEach((to, from) => {
        idle()
    })

}